<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>京东导航栏</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .nav{
            position: fixed;
            left:-2000px;
            top: 0px;
            width: 100%;
            height: 80px;
            text-align: center;
            line-height: 80px;
            background-color: purple;
            color: white;
            font-size: 30px;
            transition: all 1s;
        }
        .content{
            width: 80%;
            height: 2200px;
            margin: 0 auto;
            padding-top: 600px;
            background-color: bisque;
        }
        .sk{
            width: 400px;
            height: 300px;
            background-color: aqua;
            
            
        }
        .food{
            width: 100%;
            height: 70px;
            background-color: grey;
        }
    </style>
</head>
<body>
    <div class="nav">京东导航栏</div>
    <div class="content">
        <div class="sk">秒杀模块</div>
    </div>
    <div class="food"></div>
    <script>
        const nav = document.querySelector('.nav')
        const sk = document.querySelector('.sk')
        window.addEventListener('scroll',function(){
            const n = document.documentElement.scrollTop
            nav.style.left = n >= sk.offsetTop ? 0 : '-2000px' 
        })
    </script>
</body>
</html>